package com.wc.alorithm_blue_bridge._排序.Q3994;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/11/5 16:43
 * @description
 */
public class Answer {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HW[] hws = new HW[n];
        for (int i = 0; i < n; i++) {
            HW hw = new HW();
            hw.h = sc.nextInt();
            hw.w = sc.nextInt();
            hws[i] = hw;
        }
        Arrays.sort(hws, (o1, o2) -> o2.w - o1.w);
        int maxH = hws[0].h - 1;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (hws[i].h >= maxH) {
                ++ans;
                maxH = hws[i].h;
            }
        }
        System.out.println(ans);
    }

    static class HW {
        public int h;
        public int w;
    }
}
